var _util = require('util/util.js');

var _account_service = {
    checkLogin : function(resolve,reject){
        _util.request({
            url     : _util.getServerURL('account/get_login_account_info'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    login : function(account ,resolve,reject){
        _util.request({
            url     : _util.getServerURL('account/login'),
            data    : account,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    logout : function(resolve, reject){
        _util.request({
            url     : _util.getServerURL('account/logout'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    getAccountInformation : function(resolve,reject){
        _util.request({
            url     : _util.getServerURL('account/information'),
            method  : 'Get',
            success : resolve,
            error   : reject
        })
    },
    editAccountInformation : function(accountVO,resolve,reject){
        _util.request({
            url     : _util.getServerURL('account/update'),
            async   : true,
            dataType: 'json',
			data    : accountVO,
            method  : 'Post',
            success : resolve,
            error   : reject
        })
    },
    usernameExist : function(username,resolve,reject){
        _util.request({
            url     : _util.getServerURL('account/user_exist'),
            data    : username,
            method  : 'Post',
            success : resolve,
            error   : reject
        })
    },
    register : function(accountVO,resolve,reject){
        _util.request({
            url     : _util.getServerURL('account/register'),
            async   : true,
            dataType: 'json',
			data    : accountVO,
            method  : 'Post',
            success : resolve,
            error   : reject
        }) 
    },
    sendCode : function(memPhone,resolve,reject){
        _util.request({
            url     : _util.getServerURL('account/sendCode'),
			data    : memPhone,
            method  : 'Post',
            success : resolve,
            error   : reject
        }) 
    },
    orders : function(resolve,reject){
        _util.request({
            url     :_util.getServerURL('account/orders'),
            method  :'Get',
            success :resolve,
            error   :reject
        })
    }
};

module.exports = _account_service;